package core.cards.election.model;

import java.io.Serializable;

public class VotingCardOption implements Serializable {

	private static final long serialVersionUID = 2158997028329699909L;

	private String name;
	private int value;

	private VotingCard votingCard;

	public VotingCardOption(VotingCard votingCard) {
		this.votingCard = votingCard;
	}

	public VotingCardOption(String name, VotingCard votingCard) {
		this.setName(name);
		this.value = 0;
		this.votingCard = votingCard;
	}

	public void check() {
		if (value == 1) {
			value = 0;
			votingCard.decChecked();
		} else {
			value = 1;
			votingCard.incChecked();
		}
	}

	/**
	 * @return true je
	 */
	public boolean isChecked() {
		return value == 1;
	}

	/**
	 * @return nazwa
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @return wartość
	 */
	public int getValue() {
		return value;
	}
	
	

	/**
	 * @param nazwa, która zostanie nadana
	 */
	public void setName(String name) {
		this.name = name;
	}

	public VotingCard getVotingCard() {
		return votingCard;
	}

	public String toString() {
		return this.name + ": " + value;
	}
	
	public void incValue() {
		value++;
	}
}
